#include<iostream>
#include<algorithm>

using namespace std;

const int N=20;

bool col[N],dg[N],udg[N];
int n,sum=0;


void dfs(int u)
{
	if(n==u){
		sum++;
		return;
	}
	for(int i=0;i<n;i++){
		if(!col[i]&&!dg[u+i]&&!udg[n-u+i]){
			col[i]=dg[u+i]=udg[n-u+i]=true;
			dfs(u+1);
			col[i]=dg[u+i]=udg[n-u+i]=false;
		}
	}
}


int main()
{
	cin>>n;
	dfs(0);
	printf("%d",sum);
	return 0;
} 
